package com.woniu.platform.contorller;

import com.alibaba.fastjson.JSON;
import com.woniu.platform.entity.PlatformRecommendationRecord;
import com.woniu.platform.service.PlatformRecommendationRecordService;
import com.woniu.util.utils.HttpResult;
import com.woniu.util.utils.RequestResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/recommendationRecord")
@Slf4j
public class PlatformRecommendationRecordController {
    @Autowired(required = false)
    private PlatformRecommendationRecordService recommendationRecordService;

    /**
     * 新增推荐记录
     * @param recommendationRecord
     * @return
     */
    @PostMapping("/insertRecord")
    public HttpResult insertRecommendation(@RequestBody PlatformRecommendationRecord recommendationRecord){

        return recommendationRecordService.insertRecommendation(recommendationRecord);
    }

    /**
     * 根据核心企业id查询推荐记录
     * @param requestResult
     * @return
     */
    @PostMapping("/queryRecord")
    public HttpResult selectRecommendationByCoreId(@RequestBody RequestResult<PlatformRecommendationRecord> requestResult){
        log.info("参数为:{}", JSON.toJSONString(requestResult));
        return recommendationRecordService.selectRecommendationByCoreId(requestResult);
    }

    /**
     * 修改审核记录
     */
    @RequestMapping("/updateRecord")
    public HttpResult updateRecord(@RequestBody PlatformRecommendationRecord recommendationRecord){
        return recommendationRecordService.updateRecord(recommendationRecord);
    }
}
